package edu.pku.sei.transformation.editor.model.execution;

import org.w3c.dom.Element;

import edu.pku.sei.gefcommon.descriptor.annotation.MethodProperty;
import edu.pku.sei.modeler.model.xml.XMLUtility;
import edu.pku.sei.transformation.editor.model.ModelPackage;
import edu.pku.sei.transformation.editor.model.Relationship;

public class ControlFlow extends Edge {
	private String guard;

	public Node getSource() {
		return (Node) sourceElement;
	}

	public void setSource(Node source) {
		this.sourceElement = source;

	}

	public Node getTarget() {
		return (Node) targetElement;
	}

	public void setTarget(Node target) {
		this.targetElement = target;
	}

	@Override
	public void serialize(Element root) {
		super.serialize(root);
		XMLUtility.xmlInstance.serializeAttribute(root,
				ModelPackage.CONTROLFLOW_GUARD, guard);
	}

	@Override
	public void deSerialize(Element root) {
		super.deSerialize(root);
		this.guard = XMLUtility.xmlInstance.deSerializeString(root,
				ModelPackage.CONTROLFLOW_GUARD);
	}

	@Override
	public void dynamicSet(String featureID, Object value) {
		super.dynamicSet(featureID, value);
	}
	@MethodProperty(name = "guard", catalog = "Control Flow", setter = "setGuard", id = ModelPackage.CONTROLFLOW_GUARD)
	public String getGuard() {
		return guard;
	}

	public void setGuard(String guard) {
		String oldValue = this.guard;
		if (oldValue == null || !oldValue.equals(guard)) {
			this.guard = guard;
			this.firePropertyChange(ModelPackage.CONTROLFLOW_GUARD, oldValue, guard);
		}
	}
}
